﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Speech.Recognition;
using System.Timers;
using System.Reflection;

namespace WPF_ActiveDataObject
{
    /// <summary>
    /// Interaction logic for ActiveSpeechRecognitionEngine.xaml
    /// </summary>
    public partial class ActiveSpeechRecognitionEngine : Window
    {
        public ActiveSpeechRecognitionEngine()
        {
            InitializeComponent();

            Loaded += delegate
            {
                SpeechRecognitionEngine SRE = Resources["SRE"] as SpeechRecognitionEngine;
                SRE.SetInputToDefaultAudioDevice();
                SRE.LoadGrammar(new DictationGrammar());

                SRE.RecognizeAsync(RecognizeMode.Multiple);
            };

            Unloaded += delegate
            {
                SpeechRecognitionEngine SRE = Resources["SRE"] as SpeechRecognitionEngine;
                SRE.RecognizeAsyncCancel();
                SRE.Dispose();
            };
        }
    }
}
